package o;

import androidx.annotation.Nullable;
import com.google.android.exoplayer2.audio.AudioProcessor;
import com.google.android.exoplayer2.audio.AudioProcessor.UnhandledFormatException;
import com.huawei.hwphy2d.physical.util.BarrierParameters;
import com.tencent.mm.opensdk.constants.ConstantsAPI.AppSupportContentFlag;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;

public final class acr implements AudioProcessor {
    private int ʻ = -1;
    private ByteBuffer ʼ = ˏ;
    private ShortBuffer ʽ = this.ʼ.asShortBuffer();
    private float ˊ = 1.0f;
    private boolean ˊॱ;
    private float ˋ = 1.0f;
    private ByteBuffer ˋॱ = ˏ;
    private int ˎ = -1;
    private long ˏॱ;
    private int ॱ = -1;
    private long ॱˊ;
    @Nullable
    private acs ॱॱ;
    private int ᐝ = -1;

    public float ॱ(float f) {
        float ˋ = anr.ˋ(f, BarrierParameters.RESTITUTION, 8.0f);
        if (this.ˊ != ˋ) {
            this.ˊ = ˋ;
            this.ॱॱ = null;
        }
        ʼ();
        return ˋ;
    }

    public float ˋ(float f) {
        float ˋ = anr.ˋ(f, BarrierParameters.RESTITUTION, 8.0f);
        if (this.ˋ != ˋ) {
            this.ˋ = ˋ;
            this.ॱॱ = null;
        }
        ʼ();
        return ˋ;
    }

    public long ˋ(long j) {
        if (this.ॱˊ < AppSupportContentFlag.MMAPP_SUPPORT_XLS) {
            return (long) (((double) this.ˊ) * ((double) j));
        }
        if (this.ʻ == this.ˎ) {
            return anr.ॱ(j, this.ˏॱ, this.ॱˊ);
        }
        return anr.ॱ(j, ((long) this.ʻ) * this.ˏॱ, ((long) this.ˎ) * this.ॱˊ);
    }

    public boolean ˋ(int i, int i2, int i3) throws UnhandledFormatException {
        if (i3 != 2) {
            throw new UnhandledFormatException(i, i2, i3);
        }
        int i4 = this.ᐝ == -1 ? i : this.ᐝ;
        if (this.ˎ == i && this.ॱ == i2 && this.ʻ == i4) {
            return false;
        }
        this.ˎ = i;
        this.ॱ = i2;
        this.ʻ = i4;
        this.ॱॱ = null;
        return true;
    }

    public boolean ˏ() {
        return this.ˎ != -1 && (Math.abs(this.ˊ - 1.0f) >= 0.01f || Math.abs(this.ˋ - 1.0f) >= 0.01f || this.ʻ != this.ˎ);
    }

    public int ˋ() {
        return this.ॱ;
    }

    public int ˊ() {
        return 2;
    }

    public int ˎ() {
        return this.ʻ;
    }

    public void ˎ(ByteBuffer byteBuffer) {
        amm.ˏ(this.ॱॱ != null);
        if (byteBuffer.hasRemaining()) {
            ShortBuffer asShortBuffer = byteBuffer.asShortBuffer();
            int remaining = byteBuffer.remaining();
            this.ˏॱ += (long) remaining;
            this.ॱॱ.ॱ(asShortBuffer);
            byteBuffer.position(byteBuffer.position() + remaining);
        }
        int ˋ = (this.ॱॱ.ˋ() * this.ॱ) * 2;
        if (ˋ > 0) {
            if (this.ʼ.capacity() < ˋ) {
                this.ʼ = ByteBuffer.allocateDirect(ˋ).order(ByteOrder.nativeOrder());
                this.ʽ = this.ʼ.asShortBuffer();
            } else {
                this.ʼ.clear();
                this.ʽ.clear();
            }
            this.ॱॱ.ˎ(this.ʽ);
            this.ॱˊ += (long) ˋ;
            this.ʼ.limit(ˋ);
            this.ˋॱ = this.ʼ;
        }
    }

    public void ॱ() {
        amm.ˏ(this.ॱॱ != null);
        this.ॱॱ.ˏ();
        this.ˊॱ = true;
    }

    public ByteBuffer ʽ() {
        ByteBuffer byteBuffer = this.ˋॱ;
        this.ˋॱ = ˏ;
        return byteBuffer;
    }

    public boolean ʻ() {
        return this.ˊॱ && (this.ॱॱ == null || this.ॱॱ.ˋ() == 0);
    }

    public void ʼ() {
        if (ˏ()) {
            if (this.ॱॱ == null) {
                this.ॱॱ = new acs(this.ˎ, this.ॱ, this.ˊ, this.ˋ, this.ʻ);
            } else {
                this.ॱॱ.ˎ();
            }
        }
        this.ˋॱ = ˏ;
        this.ˏॱ = 0;
        this.ॱˊ = 0;
        this.ˊॱ = false;
    }

    public void ᐝ() {
        this.ˊ = 1.0f;
        this.ˋ = 1.0f;
        this.ॱ = -1;
        this.ˎ = -1;
        this.ʻ = -1;
        this.ʼ = ˏ;
        this.ʽ = this.ʼ.asShortBuffer();
        this.ˋॱ = ˏ;
        this.ᐝ = -1;
        this.ॱॱ = null;
        this.ˏॱ = 0;
        this.ॱˊ = 0;
        this.ˊॱ = false;
    }
}
